<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*,java.text.*" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="/static/jquery-1.3.1.js"></script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
function func(list) {
	var selectedValue = list.options[list.selectedIndex].value;
	var sub = document.myForm.action + '?selection=' + selectedValue; 
	document.myForm.action = sub;
	document.myForm.submit();
}
</script>
<title>Subjects Page</title>
</head>
<body>
<center>
<s:form name="myForm" action="subjectsPage" >
<s:select name="display" id="display" list="{'Show Enrolled Courses', 'Show All'}" 
    headerKey="" headerValue="Show Enrolled Courses/Show All" required="true" onchange="func(this);"/>
<table align="center" id="text" border=1>
<tr> 
    <th>Subject Code</th>
    <th>Subject Name</th>
    <th>Faculty Name</th>
    <th>Sem</th>
    <s:if test="%{selection=='' || selection=='Show All'}">
    <th>Enrolled</th>
    </s:if>
    <th>Grade</th>
</tr>
<s:iterator value="subjects">
<tr>
   <td>
   <s:url id="syllabus" action="syllabusPage">
   <s:param name="subjectCode" value="subjectCode"/>
   <s:param name="subjectName" value="subjectName"/>
   </s:url>
   <s:a href="%{syllabus}"><s:property value = "subjectCode"/></s:a>
   </td>
   <td><s:property value = "subjectName"/></td>
   <td><s:property value = "facultyName"/></td>
   <td><s:property value = "semesterName"/></td>
   <s:if test="%{selection=='' || selection=='Show All'}">
   <td><s:property value = "isEnrolled"/></td>
   </s:if>
   <td><s:property value = "grade"/></td>
</tr>
</s:iterator>
</table>
</s:form>
</center>
</body>
</html>